
import { defineAsyncComponent } from 'vue'

export default{

    install(app){
        // 1. 获取当前路径下的所有文件夹的index.vue
        const component = import.meta.glob('./*/index.vue')
        for(const [fullPath,fn] of Object.entries(component)){
            // 2. 通过遍历提供的完整路径构造组件名m-‘组件名’
            const componentName = 'm-' + fullPath.replace("./","").split("/")[0]
            //3.利用app.component来注册组件
            app.component(componentName,defineAsyncComponent(fn))
        }
    }

}